import { request } from "@/utils/http";
import {
  HospitalSetItem,
  ReqGetHospitalSetParams,
  ReqGetHospitalSetResponse,
  ReqUpdataHospitalSetResponse,
  reqAddHospitalSetParams,
} from "./types";
import React from "react";

// 请求获取医院的设置
export function reqGetHospitalSet(options: ReqGetHospitalSetParams) {
  // 结构赋值
  let { page, limit, hosname, hoscode } = options;
  // 返会请求后的结果
  return request.get<any, ReqGetHospitalSetResponse>(
    `/admin/hosp/hospitalSet/${page}/${limit}`,
    {
      params: {
        hosname,
        hoscode,
      },
    }
  );
}

// 请求医院新增设置
export function reqAddHospitalSet(data: reqAddHospitalSetParams) {
  return request.post<any, null>("/admin/hosp/hospitalSet/save", data);
}
// 请求id的设置
export function reqGetHospiatlSetById(id: React.Key) {
  return request.get<any, HospitalSetItem>(`/admin/hosp/hospitalSet/get/${id}`);
}
// 修改的设置
export function reqUpdateHospitalSet(data: ReqUpdataHospitalSetResponse) {
  return request.put<any, null>("/admin/hosp/hospitalSet/update", data);
}
// 删除的设置
export function reqDeleteHospitalSet(id: React.Key) {
  return request.delete<any, null>(`/admin/hosp/hospitalSet/remove/${id}`);
}
// 批量删除的设置
export function reqDeleteHospitalSetBatch(data: string[]) {
  return request.delete<any, null>(`/admin/hosp/hospitalSet/batchRemove`, {
    data,
  });
}
